<?php

namespace App\Http\Controllers\Api\V1\Resources;

use App\Models\BuyerNotice;
use Illuminate\Http\Resources\Json\JsonResource;

class HotProductResource extends JsonResource
{
    public function toArray($request)
    {
    	$data = $this->resource;
    	
        $data = [
        	'id' => $data->id,
	        'product_id' => $data->product_id,
	        'poster' => $data->poster,
	        'poster_url' => img_path($data->poster),
	        'back_color' => $data->back_color,
	        'title_alias' => $data->title_alias,
	        'title_alias_color' => $data->title_alias_color,
	        'label_text' => $data->label_text,
	        'label_text_color' => $data->label_text_color,
	        'label_back_color' => $data->label_back_color,
	        'is_today' => (bool)$data->is_today,
	        'order' => $data->order,
	        'created_at' => (string)$data->created_at,
	        
	        'product' => new ProductResource($this->whenLoaded('product')),
        ];
        
        return $data;
    }
}
